<?php
/*
# ------------------------------------------------------------------------
# JA Recently Viewed Jobs module for Joomla 1.5
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license - PHP files are GNU/GPL V2. CSS / JS are Copyrighted Commercial,
# bound by Proprietary License of JoomlArt. For details on licensing, 
# Please Read Terms of Use at http://www.joomlart.com/terms_of_use.html.
# Author: JoomlArt.com
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
# Redistribution, Modification or Re-licensing of this file in part of full, 
# is bound by the License applied. 
# ------------------------------------------------------------------------
*/


  defined('_JEXEC') or die('Retricted Access');
  if (! class_exists ( 'JAStack' )&&! class_exists ( 'SmartTrim' ))
  	require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'helper'.DS.'jahelper.php');
  global $jbconfig, $option;  

	$k = 0;
	$orderNo = 0;
	$currentTable = '';
	if($all_items){?>
	<?php if ($jbconfig['feeds']->get('show_feed', 1)) {?>
	<div align="right">
		<a href="<?php echo JRoute::_("index.php?option=com_jajobboard&view=jafeeds&layout=guide&Itemid=1000"); ?>"><?php echo JText::_('Jobs via RSS'); ?><img alt="RSS help" src="<?php echo JURI::root()."components/com_jajobboard/images/rss.gif"; ?>" /></a>
	</div>
	<?php } ?>
	
	    <ul class="list-latest-jobs" style="overflow:hidden;">
	       <?php foreach ($all_items as $item)
	       if (isset($item))
	       {
				JFilterOutput::objectHTMLSafe( $item );
	       		$alias = JFilterOutput::stringURLSafe(trim($item->title));
	           $job_detail = '';
	           if ($jbconfig['posts']->get('posts_show_job_type') && $item->cat_id_tmp){
                	if (is_array($item->cat_id))
                		$item->cat_id = implode(',',$item->cat_id);
                	$cat_names = getCategories($item->cat_id);
                	$job_detail= '<b>'.JText::_('Category').': </b>'.$cat_names;
                }
                if ($jbconfig['posts']->get('posts_show_description')){
                	$max_length = $jbconfig['posts']->get('posts_description_chars')? $jbconfig['posts']->get('posts_description_chars'):150;
                	$item->job_detail = htmlspecialchars_decode(substr(SmartTrim::trim($item->job_detail,0,$max_length),0,$max_length));
//		                	$filter	= new JFilterInput( '', '', 1, 1);
//		                	$item->job_detail = $filter->clean ( $item->job_detail );
		                	$job_detail .= '<br /><b>'.JText::_('Description').': </b>'.$item->job_detail;
                }
                if ($jbconfig['posts']->get('posts_show_posted_by') && $item->user_id){	
//                	$creator = 	JFactory::getUser($item->user_id);
                	$job_detail.= '<br /><b>'.JText::_('Created by').': </b>'.$item->user_id;
                }
                
                if ($jbconfig['posts']->get('postsshow_days_elapsed')){
                	$job_detail.= '<br /><b>'.JText::_('Created date').': </b>'.$item->created_date;
                }
	           ?>
	           <li>
	               <span class="editlinktip hasTip" title="<?php echo htmlspecialchars( $item->title) ; ?>::<?php echo htmlspecialchars($job_detail);?>">
	               		<?php $Itemid = get_Itemid(array('option'=>'com_jajobboard', 'view'=>'jajobs', 'layout'=>'jalist'));?>
                        <a href="<?php echo JRoute::_( 'index.php?option=com_jajobboard&view=jajobs&layout=jaview&cid[]='.$item->id.'&alias='.$alias.'&Itemid='.$Itemid); ?>"><?php echo $item->title; ?></a>
                   </span>
	           </li>
	           
	       <?php }?>
	    </ul>
	<?php }else{?>
	   <small><?php echo JText::_('Not viewed jobs');?></small>
	<?php }?>
	